package com.spring.appservice.web.controller;

import java.util.Map;

import javax.annotation.Resource;

import com.fasterxml.jackson.databind.util.JSONPObject;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.google.common.collect.Maps;
import com.mangofactory.swagger.annotations.ApiIgnore;
import com.spring.appservice.web.service.MainShowService;
import com.spring.security.core.util.ApplicationUtils;

@Controller
@RequestMapping(value = "/product")
@ApiIgnore
public class ProductController {
	@Resource private MainShowService mainShowService;
			
			
	//获取课程列表
    @RequestMapping(value = "/courseList")
    @ResponseBody
    public Object zoneInfocourseList(String categoryId,String kids_parkID,String pageSize,String pageIndex,String skip,
			String rows,String token,String callback) throws Exception{
    	Map<String,Object> rt = Maps.newHashMap();
    	try{
    		rt = mainShowService.courseList(categoryId, kids_parkID,pageSize, pageIndex, skip, rows, token);
    	}catch(Exception e){
    		rt.put(ApplicationUtils.STATUS, "0");
    		rt.put(ApplicationUtils.MSG, "系统异常");
    		e.printStackTrace();
    	}
        if(ApplicationUtils.isNotNull(callback)){
        	return new JSONPObject(callback, rt);
        }else{
        	return rt;
        }
    }

				
	//获取课程列表
    @RequestMapping(value = "/teacherList")
    @ResponseBody
    public Object teacherList(String kids_parkID,String pageSize,String pageIndex,String skip,
			String rows,String token,String callback) throws Exception{
    	Map<String,Object> rt = Maps.newHashMap();
    	try{
    		rt = mainShowService.teacherList(kids_parkID, pageSize, pageIndex, skip, rows, token);
    	}catch(Exception e){
    		rt.put(ApplicationUtils.STATUS, "0");
    		rt.put(ApplicationUtils.MSG, "系统异常");
    		e.printStackTrace();
    	}
        if(ApplicationUtils.isNotNull(callback)){
        	return new JSONPObject(callback, rt);
        }else{
        	return rt;
        }
    }

	//获取课程列表
    @RequestMapping(value = "/freePackage")
    @ResponseBody
    public Object freePackage(String kids_parkID,String pageSize,String pageIndex,String skip,
			String rows,String token,String callback) throws Exception{
    	Map<String,Object> rt = Maps.newHashMap();
    	try{
    		rt = mainShowService.freePackage(kids_parkID, pageSize, pageIndex, skip, rows);
    	}catch(Exception e){
    		rt.put(ApplicationUtils.STATUS, "0");
    		rt.put(ApplicationUtils.MSG, "系统异常");
    		e.printStackTrace();
    	}
        if(ApplicationUtils.isNotNull(callback)){
        	return new JSONPObject(callback, rt);
        }else{
        	return rt;
        }
    }
    
	//套餐/免费课程/免费体验预约
    @RequestMapping(value = "/bookProduct")
    @ResponseBody
    public Object bookProduct(String productId, String productType, String name, 
			String babyAge, String mobile, String captcha,String callback) throws Exception{
    	Map<String,Object> rt = Maps.newHashMap();
    	try{
    		rt = mainShowService.bookProduct(productId, productType, name, babyAge, mobile, captcha);
    	}catch(Exception e){
    		rt.put(ApplicationUtils.STATUS, "0");
    		rt.put(ApplicationUtils.MSG, "系统异常");
    		e.printStackTrace();
    	}
        if(ApplicationUtils.isNotNull(callback)){
        	return new JSONPObject(callback, rt);
        }else{
        	return rt;
        }
    }
    
}
